//
//  ZFSwiftMessage.swift
//  mapbox
//
//  Created by fyzq on 2023/11/3.
//

import UIKit
import SwiftMessages
class ZFSwiftMessage {
    
    
    public static func show(message : String,theme: Theme = .success){
        let success = MessageView.viewFromNib(layout: .cardView)
        success.configureTheme(theme)
        success.configureDropShadow()
        success.configureContent(body: message)
        success.button?.isHidden = true
        success.titleLabel?.isHidden = true
        var successConfig = SwiftMessages.defaultConfig
        successConfig.presentationStyle = .top
        successConfig.presentationContext = .window(windowLevel: UIWindow.Level.statusBar)
        SwiftMessages.show(config: successConfig, view: success)
    }
    public static func error(message : String){
        show(message: message,theme: .error)
    }
    
    public static func show(view:UIView,presentationStyle:SwiftMessages.PresentationStyle = .center,dimMode:SwiftMessages.DimMode = .gray(interactive: true),
                            presentationContext: SwiftMessages.PresentationContext = .window(windowLevel: UIWindow.Level.normal)){
        
        var config = SwiftMessages.defaultConfig
        config.presentationContext = presentationContext
        config.duration = .forever
        config.presentationStyle = presentationStyle
        config.dimMode = dimMode
        SwiftMessages.show(config: config, view: view)
    }
    
       
    public static func hide(){
        SwiftMessages.hide()
    }
    
    
}

